local _, GrifonOvaleScripts = ...

GrifonOvaleScripts.script.HUNTER.Attilio = {
	desc = "[5.4] Attilio Hunter BeastMastery,Survival",
	code =
[[

# Hunter spells and functions.

Define(a_murder_of_crows 131894)
	SpellInfo(a_murder_of_crows cd=120 focus=60)
	SpellInfo(a_murder_of_crows buff_focus_half=beast_within_buff specialization=beast_mastery)
	SpellAddTargetDebuff(a_murder_of_crows a_murder_of_crows_debuff=1)
Define(a_murder_of_crows_debuff 131894)
	SpellInfo(a_murder_of_crows duration=30)
Define(a_murder_of_crows_talent 13)
Define(aimed_shot 19434)
	SpellInfo(aimed_shot buff_focus_none=master_marksman_fire_buff focus=50)
	SpellAddBuff(aimed_shot master_marksman_fire_buff=0)
Define(arcane_shot 3044)
	SpellInfo(arcane_shot focus=30)
	SpellInfo(arcane_shot buff_focus_half=beast_within_buff specialization=beast_mastery)
	SpellInfo(arcane_shot buff_focus=thrill_of_the_hunt_buff buff_focus_amount=-20 talent=thrill_of_the_hunt_talent)
	SpellAddBuff(arcane_shot thrill_of_the_hunt_buff=-1)
	SpellAddTargetDebuff(arcane_shot hunters_mark_debuff=1)
Define(aspect_of_the_hawk 13165)
	SpellInfo(aspect_of_the_hawk cd=1)
Define(aspect_of_the_iron_hawk 109260)
	SpellInfo(aspect_of_the_iron_hawk cd=1)
Define(aspect_of_the_iron_hawk_talent 8)
Define(barrage 120360)
	SpellInfo(barrage cd=30 focus=30)
	SpellInfo(barrage buff_focus_half=beast_within_buff specialization=beast_mastery)
Define(barrage_talent 18)
Define(beast_within_buff 34471)
	SpellInfo(beast_within_buff duration=10)
	SpellInfo(beast_within_buff addduration=6 itemset=T14 itemcount=4)
Define(bestial_wrath 19574)
	SpellInfo(bestial_wrath cd=60)
	SpellInfo(bestial_wrath buff_cdr=cooldown_reduction_agility_buff)
	SpellAddBuff(bestial_wrath beast_within_buff=1)
Define(black_arrow 3674)
	SpellInfo(black_arrow cd=30 focus=35)
	SpellInfo(black_arrow addcd=-6 if_spell=trap_mastery)
	SpellInfo(black_arrow buff_cdr=cooldown_reduction_agility_buff)
	SpellAddTargetDebuff(black_arrow black_arrow_debuff=1)
Define(black_arrow_debuff 3674)
	SpellInfo(black_arrow_debuff duration=20 tick=2)
Define(bombardment_buff 82921)
	SpellInfo(bombardment_buff duration=5)
Define(chimera_shot 53209)
	SpellInfo(chimera_shot cd=9 focus=45)
	SpellAddTargetDebuff(chimera_shot serpent_sting_debuff=refresh)
	SpellAddTargetDebuff(chimera_shot hunters_mark_debuff=1)
Define(cobra_shot 77767)
	SpellInfo(cobra_shot focus=-14)
	SpellInfo(cobra_shot focus=-28 itemset=T13 itemcount=2)
Define(counter_shot 147362)
	SpellInfo(counter_shot cd=24)
Define(crouching_tiger_hidden_chimera_talent 3)
Define(deterrence 148467)
	SpellInfo(deterrence cd=5)
Define(dire_beast 120679)
	SpellInfo(dire_beast cd=30)
Define(dire_beast_talent 11)
Define(disengage 781)
	SpellInfo(disengage cd=20)
	SpellInfo(disengage addcd=-10 talent=crouching_tiger_hidden_chimera_talent)
	SpellInfo(disengage buff_cdr=cooldown_reduction_agility_buff)
Define(explosive_shot 53301)
	SpellInfo(explosive_shot cd=6 focus=25)
	SpellInfo(explosive_shot buffnocd=lock_and_load_buff buff_focus_none=lock_and_load_buff if_spell=lock_and_load)
	SpellAddBuff(explosive_shot lock_and_load_buff=-1 if_spell=lock_and_load)
	SpellAddTargetDebuff(explosive_shot hunters_mark_debuff=1)
Define(explosive_trap 13813)
	SpellInfo(explosive_trap cd=30)
	SpellInfo(explosive_trap addcd=-6 if_spell=trap_mastery)
Define(snake_trap 34600)
	SpellInfo(snake_trap cd=30)
	SpellInfo(snake_trap addcd=-6 if_spell=trap_mastery)
Define(ice_trap 13809)
	SpellInfo(ice_trap cd=30)
	SpellInfo(ice_trap addcd=-6 if_spell=trap_mastery)
Define(fervor 82726)
	SpellInfo(fervor cd=30 focus=-50)
Define(fervor_talent 10)
Define(focus_fire 82692)
	SpellAddBuff(focus_fire frenzy_buff=0)
Define(glaive_toss 117050)
	SpellInfo(glaive_toss cd=15 focus=15)
	SpellInfo(glaive_toss buff_focus_half=beast_within_buff specialization=beast_mastery)
Define(glaive_toss_talent 16)
Define(hunters_mark 1130)
Define(hunters_mark_debuff 1130)
	SpellInfo(hunters_mark_debuff duration=300)
	SpellAddTargetDebuff(hunters_mark hunters_mark_debuff=1)
Define(kill_command 34026)
	SpellInfo(kill_command cd=6 focus=40)
	SpellInfo(kill_command buff_focus_half=beast_within_buff)
	SpellAddTargetDebuff(kill_command hunters_mark=1)
Define(kill_shot 53351)
	SpellInfo(kill_shot cd=10)
Define(lock_and_load 56343)
Define(lock_and_load_buff 56453)
	SpellInfo(lock_and_load_buff duration=12 maxstacks=2)
Define(lynx_rush 120697)
	SpellInfo(lynx_rush cd=90)
	SpellAddTargetDebuff(lynx_rush lynx_rush_debuff=1)
Define(lynx_rush_debuff 120699)
	SpellInfo(lynx_rush_debuff duration=15 tick=3)
Define(lynx_rush_talent 15)
Define(master_marksman_fire_buff 82926)
	SpellInfo(master_marksman_fire_buff duration=10)
Define(misdirection 34477)
	SpellInfo(misdirection cd=30)
Define(multi_shot 2643)
	SpellInfo(multi_shot focus=40)
	SpellInfo(multi_shot buff_focus=thrill_of_the_hunt_buff buff_focus_amount=-20 talent=thrill_of_the_hunt_talent)
	SpellInfo(multi_shot buff_focus_half=beast_within_buff specialization=beast_mastery)
	SpellInfo(multi_shot buff_focus=bombardment_buff buff_focus_amount=-20 specialization=marksmanship)
	SpellAddBuff(multi_shot thrill_of_the_hunt_buff=-1)
	SpellAddTargetDebuff(multi_shot serpent_sting_debuff=1 if_spell=serpent_spread)
Define(pet_beast_cleave_buff 118455)
	SpellInfo(pet_beast_cleave_buff duration=4)
Define(frenzy_buff 19615)
	SpellInfo(frenzy_buff duration=30)
Define(powershot 109259)
	SpellInfo(powershot cd=60 focus=15)
	SpellInfo(powershot buff_focus_half=beast_within_buff specialization=beast_mastery)
Define(powershot_talent 17)
Define(pre_steady_focus_buff 53224)
Define(rapid_fire 3045)
	SpellInfo(rapid_fire cd=180)
	SpellInfo(rapid_fire buff_cdr=cooldown_reduction_agility_buff)
	SpellAddBuff(rapid_fire rapid_fire_buff=1)
Define(rapid_fire_buff 3045)
	SpellInfo(rapid_fire_buff duration=15)
Define(revive_pet 982)
	SpellInfo(revive_pet focus=35)
	SpellInfo(revive_pet buff_focus_half=beast_within_buff specialization=beast_mastery)
Define(serpent_spread 87935)
Define(serpent_sting 1978)
	SpellInfo(serpent_sting focus=15)
	SpellInfo(serpent_sting buff_focus_half=beast_within_buff specialization=beast_mastery)
	SpellAddTargetDebuff(serpent_sting serpent_sting_debuff=1)
Define(serpent_sting_debuff 118253)
	SpellInfo(serpent_sting_debuff duration=15 tick=3)
Define(silencing_shot 34490)
	SpellInfo(silencing_shot cd=24)
	SpellInfo(silencing_shot buff_cdr=cooldown_reduction_agility_buff)
Define(stampede 121818)
	SpellInfo(stampede cd=300)
	SpellInfo(stampede buff_cdr=cooldown_reduction_agility_buff)
Define(stampede_buff 121818)
Define(steady_focus 53224)
Define(steady_focus_buff 53220)
	SpellInfo(steady_focus_buff duration=20)
Define(steady_shot 56641)
	SpellInfo(steady_shot focus=-14)
	SpellInfo(steady_shot focus=-28 itemset=T13 itemcount=2)
	SpellInfo(steady_shot buff_focus=steady_focus_buff buff_focus_amount=-3 if_spell=steady_focus)
Define(thrill_of_the_hunt_buff 34720)
	SpellInfo(thrill_of_the_hunt_buff duration=15)
Define(thrill_of_the_hunt_talent 12)
Define(trap_mastery 63458)

AddFunction Interrupt
{
	if {target.IsFriend(no) or {target.IsFriend() and target.IsCharmed()} } and target.IsInterruptible()
	{
		Spell(silencing_shot)
		Spell(counter_shot)
	}
}

AddFunction SummonPet
{
	if pet.Present(no) Texture(ability_hunter_beastcall help=SummonPet)
	if pet.IsDead() Spell(revive_pet)
}

AddFunction KillCommand
{
	if pet.Present() and pet.IsIncapacitated(no) and pet.IsFeared(no) and pet.IsStunned(no) Spell(kill_command)
}

AddFunction CdActions
{
	if TalentPoints(a_murder_of_crows_talent) and not target.DebuffPresent(a_murder_of_crows_debuff) Spell(a_murder_of_crows)
	if TalentPoints(lynx_rush_talent) and not target.DebuffPresent(lynx_rush_debuff) Spell(lynx_rush)
	if TalentPoints(powershot_talent) Spell(powershot)
	if target.TimeToDie() >= 20 Spell(stampede)
	if target.TimeToDie() >= 20 Spell(rapid_fire)
}


AddFunction PrecombatActions
{
	if TalentPoints(aspect_of_the_iron_hawk_talent) and not Stance(hunter_aspect_of_the_iron_hawk) Spell(aspect_of_the_iron_hawk)
	if not TalentPoints(aspect_of_the_iron_hawk_talent) and not Stance(hunter_aspect_of_the_hawk) Spell(aspect_of_the_hawk)
	SummonPet()
}

AddCheckBox(AutoInterrupt "AutoInterrupt" default)
AddCheckBox(AutoCD "AutoCD" default)
AddCheckBox(AutoCDOnlyOnBOSS "AutoCDOnlyOnBOSS" default)
AddCheckBox(AutoMark "AutoMark" )
AddCheckBox(AutoTrap "AutoTrap" default)
AddCheckBox(ExplosiveTrap "ExplosiveTrap" default)
AddCheckBox(SnakeTrap "SnakeTrap" default)
AddCheckBox(IceTrap "IceTrap" )
AddCheckBox(AutoAOEOnSingleTarget "AutoAOEOnSingleTarget" default)



###
### Beast Mastery
###

AddFunction BeastMasterySingleTarget
{	
	PrecombatActions()
	if CheckBoxOn(AutoInterrupt) Interrupt()
	if CheckBoxOn(AutoMark) and target.TimeToDie() >= 20 and not target.DebuffPresent(ranged_vulnerability any=1) Spell(hunters_mark)
	if Focus() > 60 and not BuffPresent(beast_within_buff) and not BuffPresent(bestial_wrath) Spell(bestial_wrath)
	if BuffStacks(frenzy_buff any=1) == 5 and not BuffPresent(beast_within_buff) Spell(focus_fire)
	Spell(kill_shot usable=1)
	KillCommand()
	if not target.DebuffPresent(serpent_sting_debuff) and target.TimeToDie() >= 10 Spell(serpent_sting)
	if TalentPoints(glaive_toss_talent) Spell(glaive_toss)
        if TalentPoints(barrage_talent) Spell(barrage)	
	if TalentPoints(dire_beast_talent) Spell(dire_beast)
	if TalentPoints(fervor_talent) and Focus() <= 50 Spell(fervor)			
	if BuffPresent(thrill_of_the_hunt_buff) or BuffPresent(beast_within_buff) Spell(arcane_shot)			
	if target.DebuffRemains(serpent_sting_debuff) < 6 and Focus() < 100 and target.TimeToDie() >= 5 Spell(cobra_shot)	
	if Focus() >= 70 
	{
		if CheckBoxOn(AutoAOEOnSingleTarget) and Enemies() >= 2
		{
			Spell(multi_shot)
		}
		Spell(arcane_shot)
	}
	if CheckBoxOn(AutoCD) 
	{
		if CheckBoxOn(AutoCDOnlyOnBOSS) and target.Classification(worldboss) CdActions()
		if not CheckBoxOn(AutoCDOnlyOnBOSS) CdActions()
	}
	if CheckBoxOn(AutoAOEOnSingleTarget) and Enemies() >= 5 and Speed()==0 and CheckBoxOn(AutoTrap) 
	{
		if CheckBoxOn(ExplosiveTrap) Spell(explosive_trap)
		if CheckBoxOn(SnakeTrap) Spell(snake_trap)
		if CheckBoxOn(IceTrap) Spell(ice_trap)
	}
	Spell(cobra_shot)
}

AddFunction BeastMasteryAOE
{	
	PrecombatActions()
	if CheckBoxOn(AutoInterrupt) Interrupt()
	if Focus() > 60 and not BuffPresent(beast_within_buff) and not BuffPresent(bestial_wrath) Spell(bestial_wrath)
	if BuffStacks(frenzy_buff any=1) == 5 Spell(focus_fire)
	Spell(multi_shot)
	Spell(kill_shot usable=1)
	KillCommand()
	if TalentPoints(glaive_toss_talent) Spell(glaive_toss)
        if TalentPoints(barrage_talent) Spell(barrage)	
	if TalentPoints(dire_beast_talent) Spell(dire_beast)
	if TalentPoints(fervor_talent) and Focus() <= 50 Spell(fervor)						
	if CheckBoxOn(AutoCD) 
	{
		if CheckBoxOn(AutoCDOnlyOnBOSS) and target.Classification(worldboss) CdActions()
		if not CheckBoxOn(AutoCDOnlyOnBOSS) CdActions()
	}
	if Speed()==0 and CheckBoxOn(AutoTrap) 
	{
		if CheckBoxOn(ExplosiveTrap) Spell(explosive_trap)
		if CheckBoxOn(SnakeTrap) Spell(snake_trap)
		if CheckBoxOn(IceTrap) Spell(ice_trap)
	}	
	Spell(cobra_shot)
}

### Beast Mastery icons


AddIcon specialization=1 help=single
{
	BeastMasterySingleTarget()
}

AddIcon specialization=1 help=aoe
{
	BeastMasteryAOE()
}



###
### Survival
###

AddFunction SurvivalSingleTarget
{
	PrecombatActions()
	if CheckBoxOn(AutoInterrupt) Interrupt()
	if CheckBoxOn(AutoMark) and target.TimeToDie() >= 20 and not target.DebuffPresent(ranged_vulnerability any=1) Spell(hunters_mark)
	Spell(kill_shot usable=1)
	if not target.DebuffPresent(serpent_sting_debuff) and target.TimeToDie() >= 10 Spell(serpent_sting)
	Spell(explosive_shot)
	Spell(kill_shot usable=1)
	if {{CheckBoxOn(AutoAOEOnSingleTarget) and Enemies() < 3} or not CheckBoxOn(AutoAOEOnSingleTarget)} 
		and not target.DebuffPresent(black_arrow_debuff) and target.TimeToDie() >= 8 Spell(black_arrow)
	if TalentPoints(glaive_toss_talent) Spell(glaive_toss)
        if TalentPoints(barrage_talent) Spell(barrage)	
	if TalentPoints(dire_beast_talent) Spell(dire_beast)
	if TalentPoints(fervor_talent) and Focus() <= 50 Spell(fervor)						
	if target.DebuffRemains(serpent_sting_debuff) < 6 and target.TimeToDie() >= 5 and Focus() < 100 Spell(cobra_shot)	
	if Focus() >= 70 or {BuffPresent(thrill_of_the_hunt_buff) and Focus() >=10}
	{
		if CheckBoxOn(AutoAOEOnSingleTarget) and Enemies() >= 2
		{
			Spell(multi_shot)
		}
		Spell(arcane_shot)
	}
	if CheckBoxOn(AutoCD) 
	{
		if CheckBoxOn(AutoCDOnlyOnBOSS) and target.Classification(worldboss) CdActions()
		if not CheckBoxOn(AutoCDOnlyOnBOSS) CdActions()
	}
	if CheckBoxOn(AutoAOEOnSingleTarget) and Enemies() >= 5 and Speed()==0 and CheckBoxOn(AutoTrap) 
	{
		if CheckBoxOn(ExplosiveTrap) Spell(explosive_trap)
		if CheckBoxOn(SnakeTrap) Spell(snake_trap)
		if CheckBoxOn(IceTrap) Spell(ice_trap)
	}
	Spell(cobra_shot)
}

AddFunction SurvivalAOE
{
	PrecombatActions()
	if CheckBoxOn(AutoInterrupt) Interrupt()
	Spell(multi_shot)
	Spell(kill_shot usable=1)
	if TalentPoints(glaive_toss_talent) Spell(glaive_toss)
        if TalentPoints(barrage_talent) Spell(barrage)	
	if TalentPoints(dire_beast_talent) Spell(dire_beast)
	if TalentPoints(fervor_talent) and Focus() <= 50 Spell(fervor)						
	if CheckBoxOn(AutoCD) 
	{
		if CheckBoxOn(AutoCDOnlyOnBOSS) and target.Classification(worldboss) CdActions()
		if not CheckBoxOn(AutoCDOnlyOnBOSS) CdActions()
	}
	if Speed()==0 and CheckBoxOn(AutoTrap) 
	{
		if CheckBoxOn(ExplosiveTrap) Spell(explosive_trap)
		if CheckBoxOn(SnakeTrap) Spell(snake_trap)
		if CheckBoxOn(IceTrap) Spell(ice_trap)
	}	
	Spell(cobra_shot)
	
}


AddIcon specialization=3 help=single
{
	SurvivalSingleTarget()
}

AddIcon specialization=3 help=aoe
{
	SurvivalAOE()
}































































]]
}
